<?php 
/*
	Copyright 2006, 2007, 2008, 2009, 2010 Bastiaan Grutters
    
    This file is part of Ages of Strife website.

    Ages of Strife website is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Ages of Strife website is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Ages of Strife website.  If not, see <http://www.gnu.org/licenses/>.
 */
global $language;
$language = 'en';
header( 'Content-type: text/html; charset=utf-8' );
include_once( "global/old_database_connection.php" );
include( "global/translations.php" );
$query5 = "SELECT language, title " .
		"FROM languages " .
		"ORDER BY default_language DESC, title ASC";
$result5 = mysql_query( $query5 ) or die( "Query failed : " . mysql_error() );
$num5 = mysql_numrows( $result5 );
if( isset( $_GET[ 'language' ] ) ) {
	$i = 0;
	while ( $i < $num5 ) {
		if( $_GET[ 'language' ] == mysql_result( $result5, $i, 'language' ) ) {
			$language = mysql_result( $result5, $i, 'language' );
			break;
		}
		$i ++;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>Ages of Strife: <?php transprint( 'Register' ); ?></title>
		<link rel="stylesheet" href="global/agesofstrife.css"></link>
		<script language="JavaScript" type="text/javascript" src="global/global.js"></script>
	</head>
	<body>
		<div id="root_container">
			<div align="center" id="header-image">
				<a href="index.php?language=<?php print( $language ); ?>">
					<img class="header-dummy-image" src="resources/dummy.gif" alt="Ages of Strife" border="0" />
				</a>
			</div>
<?php
include( "global/ads.php" );
include( "global/utils.php" );
?>
			<div id="container">
				<div id="main-content">
					<h2>Ages of Strife: <?php transprint( 'Register' ); ?></h2><br />
					<br />
					<div class="blok">
						<?php transprint( 'Language' ); ?>:&nbsp;
<?php
	$i = 0;
	while ( $i < $num5 ) {
		if( $i > 0 ) {
			print( ', ' );
		}
		if( $language == mysql_result( $result5, $i, 'language' ) ) {
			print( '<strong>' . mysql_result( $result5, $i, 'title' ) . ' (' . mysql_result( $result5, $i, 'language' ) . ')</strong>' );
		}
		else {
			print( '<a href="register.php?language=' . mysql_result( $result5, $i, 'language' ) . '">' . mysql_result( $result5, $i, 'title' ) . ' (' . mysql_result( $result5, $i, 'language' ) . ')</a>' );
		}
		$i ++;
	}
?>
					</div>
					<br />
<?php
$username = "";
$message = "";
$email = "";

if( isset( $_GET[ 'message' ] ) ) {
	$message = formatInputLetter( $_GET[ 'message' ] );
}
if( isset( $_GET[ 'username' ] ) ) {
	$username = formatInputLetter( $_GET[ 'username' ] );
}
if( isset( $_GET[ 'email' ] ) ) {
	$email = formatInputLetter( $_GET[ 'email' ] );
}

if( $message != '' ) {
?>
					<div class="blok">
						<strong><?php transprint( 'Status' ); ?></strong>: <?php print( translate( $message ) ); ?> 
					</div>
					<br />
<?php
}
?>
					<form action="global/create_user.php" method="post" id="form">
						<table id="blank">
							<tr id="even">
								<td><?php transprint( 'Username' ); ?>:</td>
								<td>
									<input type="text" name="username" value="<?php print( $username ); ?>" size="40" />
									<input type="hidden" name="language" value="<?php print( $language ); ?>" />
								</td>
							</tr>
							<tr>
								<td><?php transprint( 'Password' ); ?></td>
								<td><input type="password" name="password" size="40"/></td>
							</tr>
							<tr id="even">
								<td><?php transprint( 'Password confirm' ); ?></td>
								<td><input type="password" name="password2" size="40"/></td>
							</tr>
							<tr>
								<td><?php transprint( 'E-mail address' ); ?><br /></td>
								<td><input type="text" name="email" value="<?php print( $email ); ?>" size="40"/></td>
							</tr>
							<tr id="even">
								<td><input type="button" value="<?php transprint( 'Register' ); ?>" id="button" onclick="disableElement( 'button', 'form' )" /></td>
								<td>&nbsp;</td>
							</tr>
						</table>
					</form>
					<br />
<?php
include( 'global/game_rules.php' );
?>		
				</div>
			</div>
		</div>
	</body>
</html>